from django.contrib import admin
from bibliophile.models import Author, Book, Progress

class AuthorAdmin(admin.ModelAdmin):
    list_display = ('last_name', 'first_name', 'website')
    prepopulated_fields = {'slug': ('first_name', 'last_name')}

class ProgressInline(admin.TabularInline):
    model = Progress

class ProgressAdmin(admin.ModelAdmin):
    list_display = ('book', 'milestone', 'date_achieved')

class BookAdmin(admin.ModelAdmin):
    list_display = ('title', 'authors', 'progress', 'user')
    list_filter = ('show_progress', 'date_added', 'author')
    search_fields = ('title', 'description', 'isbn_10')
    prepopulated_fields = {'slug': ('title',)}

    inlines = (ProgressInline,)

admin.site.register(Author, AuthorAdmin)
admin.site.register(Book, BookAdmin)
admin.site.register(Progress, ProgressAdmin)
